﻿using System;
using System.Collections.Generic;
using System.Web.UI.WebControls;
using BIS.Portal.Core.Base;
using BIS.Portal.Core.Global;
using BIS.Portal.Modules.CMS.BO;
using BIS.Portal.Modules.CMS.Entity;
using BIS.Utility.Converter;

namespace BIS.Portal.Modules.CMS
{
    public partial class CmsFreeMedia : ControlBase
    {
        #region Load Data Settings

        public string ArticleFreeText
        {
            get
            {
                return GetControlSetting<string>(ModuleSettingNames.CmsFreeMedia.ddlArticleFreeText, PortalContext.LanguageAlias);
            }
        }
        public string SLAnhHienThi
        {
            get
            {
                return GetControlSetting<string>(ModuleSettingNames.CmsFreeMedia.txtSLAnh, PortalContext.LanguageAlias);
            }
        }
        #endregion
        protected void Page_Load(object sender, EventArgs e)
        {
            loaddata();
        }
        private void  loaddata()
        {
        IList<ClientCmsArticleFreeMediaEntity> list= ClientCmsArticleBO.GetFreeMediaByArticleId(PortalContext.LanguageInUseId, Functions.GetInt(ArticleFreeText),
                                                       Functions.GetInt(SLAnhHienThi));
            Media_Anh.DataSource = list;
            Media_Anh.DataBind();
        }
        protected void Media_Anh_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if ((e.Item.ItemType == ListItemType.Item) || (e.Item.ItemType == ListItemType.AlternatingItem))
            {
                ClientCmsArticleFreeMediaEntity obj = (ClientCmsArticleFreeMediaEntity) e.Item.DataItem;
                Image imgAnh = e.Item.FindControl("Anh_Minh_Hoa") as Image;
                if (imgAnh != null) imgAnh.ImageUrl = obj.MediaThumbnails;
            }
        }
    }
}